<%@ taglib prefix="tpl" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page import="shop.bean.UserBean"%>


<tpl:header title="Administration" />

<%
	if (((UserBean) session.getAttribute("currentUser")).getRole() == null) {
%>

You are not allowed to access the administration.

<%
	} else {
%>

<h1>Welcome to the admin page</h1>

<form method="post"> 
	<table>
		<thead>
			<tr>
				<th>Name</th>
				<th>Quantity</th>
				<th>Add</th>
			</tr>
		</thead>
		<c:forEach var="entry" items="${offers}">
			<tr>
				<td>${entry.name}</td>
				<td>${entry.quantity}</td>
				<td><input type="text" name="${entry.id}" size="5" /></td>
			</tr>
		</c:forEach>
	</table>

	<input type="submit" value="Change stocks" />
</form>

<br />
<br />
<br />

<h2>Add a new product</h2>
<form method="post">
	<table>
		<thead>
			<tr>
				<th colspan="2">Product informations</th>
		</thead>
		<tr>
			<td>Name:</td>
			<td><input type="text" name="name" /></td>
		<tr>
			<td>Country:</td>
			<td><select name="country">
					<option value="0">Germany</option>
					<option value="1">France</option>
			</select></td>
		</tr>
		<tr>
			<td>Region:</td>
			<td><input type="text" name="region" /></td>
		</tr>
		<tr>
			<td>Description:</td>
			<td><textarea name="description" rows="6" cols="50"></textarea></td>
		<tr>
			<td>Price:</td>
			<td><input type="text" name="price" /></td>
		</tr>
	</table>
	
	<input type="submit" value="Create Product" />
</form>


<%
	}
%>

<tpl:footer />